import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login.vue'

Vue.use(VueRouter)

let originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(path){
  return originalPush.call(this,path).catch(err=>err)
}

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '@/components/dashboard/Dashboard'),
    // children:[
    //   {
    //     path:'',
    //     name:'home',
    //     component: () => import('@/components/dashboard/Home'),
    //     meta:['数据管理'],
    //   },
    // ]
  }
]

const router = new VueRouter({
  routes
})

export default router
